/**
 * Project Name:scb_sms
 * File Name:MenuController.java
 * Package Name:com.scb.dev.sms.controller
 * Date:Nov 20, 20181:16:57 PM
 * Copyright (c) 2018, Y-Rainson All Rights Reserved.
 *
 */
package com.scb.dev.mms.controller;

import com.scb.dev.mms.common.ResponseResult;
import com.scb.dev.mms.pojo.Menu;
import com.scb.dev.mms.service.IMenuService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;



/**
 * ClassName: MenuController <br/>
 * Description: TODO ADD REASON(可选). <br/><br/>
 * date: Nov 20, 2018 1:16:57 PM <br/>
 *
 * @author Y-Rainson
 * @version V1.0
 * @since JDK 1.8
 */
@Controller
@ResponseBody
@RequestMapping("/sm/menu/")
@Api(value = "MenuController", description = "Menu API")
public class MenuController {
	
	@Autowired
	private IMenuService menuService;

	/**  
	 * @Title: addMenu
	 * @Description: add a new menu
	 * @Param: Menu menu
	 * @RrturnType: ResponseResult
	 */
	@RequestMapping(value = "menu",method = RequestMethod.POST)
	@ApiOperation(value="add menu", notes="Use this API to add a new menu.")
	public ResponseResult addMenu(@RequestBody
									  @ApiParam(name="menu",value="menu entity")
											  Menu menu) {
		return menuService.addMenu(menu);
	}
	
	/**  
	 * @Title: deleteMenu
	 * @Description: delete a menu
	 * @Param: String menuId
	 * @RrturnType: ResponseResult
	 */
	@RequestMapping(value = "menu/{menuId}",method = RequestMethod.DELETE)
	@ApiOperation(value="deleteDepartment", notes="Use this API to delete a department.")
	@ApiImplicitParam(paramType ="path",name = "menuId",value = "menu id",required = true ,dataType = "String")
	public ResponseResult deleteMenu(@PathVariable("menuId") String menuId) {
		return menuService.deleteMenu(menuId);
	}
	
	
	/**  
	 * @Title: updateMenu  
	 * @Description: update menu
	 * @Param: Menu menu
	 * @RrturnType: ResponseResult
	 */
	@RequestMapping(value = "menu",method = RequestMethod.PUT)
	@ApiOperation(value="updateMenu", notes="Use this API to update a menu.")
	public ResponseResult updateMenu(@RequestBody
										 @ApiParam(name="menu",value="menu entity")
												 Menu menu) {
		return menuService.updateMenu(menu);
	}
	
	/**  
	 * @Title: generateMenuTree  
	 * @Description: generate menu tree
	 * @Param: 
	 * @RrturnType: ResponseResult
	 */
	@RequestMapping(value = "menu/{roleId}",method = RequestMethod.GET)
	@ApiOperation(value="generateMenuTree", notes="Use this API to generate menuTree by role id.")
	@ApiImplicitParam(paramType ="path",name = "roleId",value = "role id",required = true ,dataType = "String")
	public ResponseResult generateMenuTree(@PathVariable  String roleId) {
		System.out.println("访问 + 1");
		return menuService.generateMenuTree(roleId);
	}
}
